from SimpleXMLRPCServer import *
from clientrequesthandler import *
import xmlrpclib
import sys
import pickle
import string

class Server(SimpleXMLRPCServer):
    def _dispatch(self, method, params):
        try:
            response = SimpleXMLRPCServer._dispatch(self, method, params)
            return pickle.dumps(response)
        except:
            trace = string.join(traceback.format_exc(sys.exc_info()))
            print trace
            raise xmlrpclib.Fault(1, trace)

clientRequestHandler = ClientRequestHandler()
server = Server(("localhost", 48879), SimpleXMLRPCRequestHandler, allow_none=True)
server.register_instance(clientRequestHandler)
print "Entering serving loop..."
server.serve_forever()